﻿using PLCS.Application.Contracts.UserApp.Dtos;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace PLCS.App.Shared.Converts
{
    public class RoleToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 获取用户权限
            var user = (UserDto)value;

            // 判断用户权限是否为 "开发者"，如果是则返回 Visibility.Visible，否则返回 Visibility.Collapsed
            if (user.RolesString.Contains("开发者"))
            {
                return Visibility.Visible;
            }
            else
            {
                return Visibility.Collapsed;
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}